home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / c_toolbx.arc / VIEWEXEC.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-03-30  |  1.5 KB  |  53 lines

  1. /* viewexec.c  file - executes one input command  */
  2. #include "stdio.h"
  3. #include "viewcmds.h"
  4. #include "viewparm.h"
  5. extern     long filesize ;        /* position of effective eof    */
  6.  
  7. int exec_cmd(cmd)            /* execute input command    */
  8.   int cmd ;                /* value of command to execute    */
  9.   {
  10.     long new_pos ,  get_pos() ;
  11.  
  12.     switch( cmd )
  13.     { case PREVPAGE    :        /* move backward to last page    */
  14.        move_backward(PAGE_SIZE - LINES_OVERLAP) ;
  15.        display_page()  ;
  16.        break ;
  17.       case NEXTPAGE    :        /* moves forward to next page    */
  18.        move_forward(PAGE_SIZE - LINES_OVERLAP) ;
  19.        display_page()  ;
  20.        break ;
  21.       case EXITPGM    :
  22.        break ;
  23.       case MOVETOPOS    :
  24.        new_pos = get_pos()    ;    /* get new file position    */
  25.        move_to(new_pos)    ;    /* move to specified position    */
  26.        set_top_page()    ;    /* make it top_of_page for now    */
  27.        move_backward(0)    ;    /* move to start of this line    */
  28.        display_page()    ;
  29.        break    ;
  30.       case FIRSTPAGE    :
  31.        move_to(0L)        ;    /* move to begining of file    */
  32.        set_top_page()    ;    /* make it the top of the page    */
  33.        display_page()    ;
  34.        break    ;
  35.       case LASTPAGE    :
  36.        move_to(filesize)    ;    /* move to end of file        */
  37.        set_top_page()    ;    /* make it the top of page    */
  38.        move_backward(PAGE_SIZE);    /* put eof at bottom        */
  39.        display_page()    ;
  40.        break    ;
  41.       case PREVLINE    :
  42.        move_backward(1)    ;    /* move back one line        */
  43.        display_page()    ;
  44.        break    ;
  45.       case NEXTLINE    :
  46.        move_forward(1)    ;    /* move forward one line    */
  47.        display_page()    ;
  48.        break    ;
  49.     }
  50.   }
  51.  
  52.  
  53.